package com.framework.controller;

import com.framework.entity.work.WorkApply;
import com.framework.entity.work.WorkTransfer;
import com.framework.entity.work.WorkUntie;
import com.framework.exception.util.RespResult;
import com.framework.service.WorkApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 功能描述: 工单申请控制器
 *
 * @author ck
 * @date 2018/9/18 11:48
 */
@RestController
@Api(value="工单申请模块",tags={"工单申请模块"})
@RequestMapping(value = "work")
public class WorkController {

	@Autowired
	private WorkApplyService workApplyService;

	/**
	 * 申请终端回拨
	 * @param token
	 * @param sns
	 * @param backPhone
	 * @return
	 */
	@PostMapping("user/insertTerBack")
	@ApiOperation("申请终端回拨")
	@ApiImplicitParams({
			@ApiImplicitParam(name="sns",value="终端号",dataType="Arrays", paramType = "query" ,required = true),
			@ApiImplicitParam(name="backPhone",value="接收人手机号码",dataType="string", paramType = "query" ,required = true)
	})
	public RespResult insertTerBack(String token,String[] sns,String backPhone) {
		workApplyService.insertTerBack(token,sns,backPhone);
		return RespResult.ok();
	}

	/**
	 * 增加终端转移
	 * @param token
	 * @param workBack
	 * @param acceptPhone
	 * @param thisPhone
	 * @return
	 */
	@PostMapping("user/insertTerTransfer")
	@ApiOperation("申请终端转移")
	@ApiImplicitParams({
			@ApiImplicitParam(name="acceptPhone",value="接收人手机号码",dataType="int", paramType = "query" ,required = true),
			@ApiImplicitParam(name="thisPhone",value="当前所属人手机号码",dataType="int", paramType = "query" ,required = true),
			@ApiImplicitParam(name="deptId",value="渠道id",dataType="Long", paramType = "query" ,required = false)
	})
	public RespResult insertTerTransfer(String token, WorkTransfer workBack, String acceptPhone, String thisPhone,Long deptId) {
		workApplyService.insertTerTransfer(token,workBack,acceptPhone,thisPhone,deptId);
		return RespResult.ok();
	}

	/**
	 * 增加终端解绑
	 * @param token
	 * @param workBack
	 * @return
	 */
	@PostMapping("user/insertTerUntie")
	@ApiOperation("申请终端解绑")
	public RespResult insertTerUntie(String token,WorkUntie workBack) {
		workApplyService.insertTerUntie(token,workBack);
		return RespResult.ok();
	}

	/**
	 * 申请其它类型的工单
	 * @param workApply
	 * @param token
	 * @param logPhone
	 * @return
	 */
	@PostMapping("user/insertWorkApply")
	@ApiOperation("申请其它类型的工单")
	@ApiImplicitParams({
			@ApiImplicitParam(name="logPhone",value="登录手机号码",dataType="string", paramType = "query" ,required = true),
			@ApiImplicitParam(name = "deptId",value ="渠道id",dataType = "Long",paramType = "query",required = false)
	})
	public RespResult insertWorkApply(WorkApply workApply, String token, String logPhone,Long deptId) {
		workApplyService.insertWorkApply(workApply,token,logPhone,deptId);
		return RespResult.ok();
	}
}
